/*
 * @Description:系统信息相关API
 * @Author: wangfuwei
 * @Date: 2020-12-08 13:46:43
 * @LastEditors: wangfuwei
 * @LastEditTime: 2021-04-25 21:30:26
 * @FilePath: /horizon-frontend/src/api/system.js
 */
import request from "@/utils/request";

const actions = {
  getLockedApps: "/system/getLockedApps",
  getMenus: "/system/getMenus",
  lockApp: "/system/lockApp",
  getCloudApps: "/system/getCloudApps",
  getMotto: "/system/getMotto",
};

/**
 * 用户锁定的应用
 */
export function getLockedApps() {
  return request.get(actions.getLockedApps);
}

/**
 * 应用下的菜单信息
 */
export function getMenus(appCode) {
  return request.get(actions.getMenus, { params: { appCode } });
}

/**
 * 锁定或解锁应用
 * @param appCode:应用编码|String
 * @param lock:是否锁定|Boolean
 */
export function lockApp(appCode, lock) {
  return request.post(actions.lockApp, { appCode, lock });
}

/**
 * 用户拥有权限的应用
 * @returns
 * {
 *  code:200,
 *  message:"",
 *  result:{
 *    fdId:[ID|String],
 *    code:[编码|String],
 *    picture:[背景图片|String],
 *    i18n: {
 *      name: {
 *        "zh-CN": [名称|String]
 *      },
 *    },
 *    children:[
 *      {
 *        fdId:[ID|String],
 *        code:[编码|String],
 *        home:[首页|String]，
 *        i18n: {
 *          name: {
 *            "zh-CN": [名称|String]
 *          },
 *          description: {
 *            "zh-CN": [描述|String]
 *          }
 *        }
 *      }
 *    ]
 * }
 */
export function getCloudApps() {
  return request.get(actions.getCloudApps);
}

/**
 * 随机获取鸡汤
 */
export function getMotto() {
  return request.get(actions.getMotto);
}
